package com.example.demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.demo.common.ReState;
import com.example.demo.entity.Tbuser;
import com.example.demo.service.TbuserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/Tbuser")
public class TbuserController {

    @Autowired
    private TbuserService tbuserService;

    @RequestMapping("/save")
    public String save(Tbuser tbuser){
        JSONObject jsonObject=new JSONObject();
        try{
            tbuserService.save(tbuser);
            jsonObject.put("code", ReState.SUCCESS);
        }
        catch (Exception e){
            e.printStackTrace();
            jsonObject.put("code", ReState.ERROR);
        }
        return jsonObject.toJSONString();
    }
}
